package generic;

import java.time.LocalDate;

public class pairTest {
    public static void main(String[] args){
        /*String[] words = {"Mary","had","a","little","lamb"};
        Pair<String> mm = ArrayAlg.minmax(words);
        System.out.println(mm.getFirst());
        System.out.println(mm.getSecond());
        String middle = ArrayAlg.getMiddle("john","q","public");
        System.out.println(middle);*/
      /*  LocalDate[] birthdays = {
                LocalDate.of(1906,12,9),
                LocalDate.of(1926,12,9),
                LocalDate.of(1936,12,9)
        };
        Pair<LocalDate> mm = ArrayAlg.minmax(birthdays);
        System.out.println(mm.getFirst());
        System.out.println(mm.getSecond());*/
      Runnable r = ()->{int i=0;while(true){i++;System.out.println(i);}};
      Thread thread = new Thread(r);
      thread.start();
    }


}

class ArrayAlg{
    public static <T> T getMiddle(T...a){
        return a[a.length/2];
    }
    public static <T extends  Comparable> Pair<T> minmax(T[] a){
        if(a == null|| a.length == 0) return null;
        T min = a[0];
        T max = a[0];
        for(int i=0;i<a.length;i++){
            if(min.compareTo(a[i] )> 0) min = a[i];
            if(max.compareTo(a[i] )< 0) max = a[i];
        }
        return new Pair<>(min,max);
    }
}
